/**
 * Created by qingxi on 2017/1/12.
 */
define(['app','module/categoryNav/services'],function(app){





    app.controller('navCtrl',['$scope','getData',function($scope,getData){
        //商城导航列表
        getData.rData('','',$scope,'getsitenav');
    }])




    app.controller('gsproductCtrl',['$scope','$http','getData','qx',function($scope,$http,getData,qx){
        //店铺列表
        getData.rData('','',$scope,'getgsshop');

        //区域列表
        $http({
            url:'http://192.168.127.222:9090/api/getgsshoparea',
            cache:true
        }).then(function(data){
            $scope.areaData=data.data.result;
        })



        $scope.shopid=0;
        $scope.areaid=0;
        //初始商品列表
        getData.rData(0,0,$scope,'getgsproduct');

        //选择店铺
        $scope.shopClick=function(id){
            $scope.shopid=id;
            getData.rData(id,$scope.areaid,$scope,'getgsproduct');
        }
        //选择区域
        $scope.areaClick=function(id){
            $scope.areaid=id;
            getData.rData($scope.shopid,id,$scope,'getgsproduct');
        }

        //下拉箭头
        $scope.navData=[{id:0,name:'京东',status:false},{id:1,name:'华北',status:false},{id:2,name:'1元',status:false}];
        $scope.navid=3;
        $scope.arrow = function(id){
            $scope.navid=id;
            var beforeStatus=$scope.navData[id].status;
            //点击时先让数组中每个对象的status为false
            qx.qxClick($scope);
            $scope.navData[id].status=beforeStatus;
            //让点击的当前的对应id的对象的status为true
            if($scope.navData[id].id==$scope.navid) $scope.navData[id].status = !$scope.navData[id].status;
        }

        //条件筛选完后让navData里的每个对象的status为false
        $scope.qxClick=function(){
            qx.qxClick($scope);
        }
    }])

})